(function ($, window, document, undefined) {

$(document).ready(function() {
	
	$klass = $.klass;
	$proto = $klass.prototype;
	$klassPath = $.klassPath;

	
	module("Namespace");
	
	test("Basic tests", 96, function() {
		
		defaultScope = $klassPath.scope.defaultScope;
		
		windowScope = $klassPath.scope(window);
		strictEqual($klassPath.scope.defaultScope, window, "$klassPath.scope.defaultScope === window");
		strictEqual(windowScope, window._scope, "windowScope === window._scope");
		
		scope = defaultScope;
		
		_flavor_sweet_Chocolate = $klass("flavor.sweet.Chocolate", {});
		strictEqual(_flavor_sweet_Chocolate, scope.flavor.sweet.Chocolate, "_flavor_sweet_Chocolate === scope.flavor.sweet.Chocolate");
		strictEqual(_flavor_sweet_Chocolate, windowScope.get("flavor.sweet.Chocolate"), '_flavor_sweet_Chocolate === windowScope.get("flavor.sweet.Chocolate")');
		
		var argsList, i, j, args;
		
		argsList = [];
		var Base_kp = [ ["Base"], [scope, "Base"], [$klassPath("Base")], [$klassPath(scope, "Base")] ];
		for(i=0; i<Base_kp.length; i++) {
			args = [];
			$.merge(args, Base_kp[i]).push({});
			argsList.push(args);
		}
		
		for(i=0; i<argsList.length; i++) {
			if(i === -1) debugger;
			delete scope.Base;
			_Base = $klass.apply(undefined, argsList[i]);
			strictEqual(_Base, scope.Base, '_Base === scope.Base (' + i + ')');
			strictEqual(_Base, windowScope.get("Base"), '_Base === windowScope.get("Base") (' + i + ')');
			strictEqual(_Base, $klassPath("Base").get(), '_Base === $klassPath("Base").get() (' + i + ')');
		}
		
		Base_kp.unshift([_Base]);
		
		argsList = [];
		var Flavor_kp = [ ["flavor.Flavor"], [scope, "flavor.Flavor"], [$klassPath("flavor.Flavor")], [$klassPath(scope, "flavor.Flavor")] ],
			first_kp = Flavor_kp,
			second_kp = Base_kp;
		//first_kp = Base_kp; second_kp = Flavor_kp;	// Uncomment to test the opposite order.
		for(i=0; i<first_kp.length; i++) {
			for(j=0; j<second_kp.length; j++) {
				args = [];
				$.merge($.merge(args, first_kp[i]), second_kp[j]).push({});
				argsList.push(args);
			}
		}
		
		for(i=0; i<argsList.length; i++) {
			if(i === -1) debugger;
			delete scope.flavor.Flavor;
			_flavor_Flavor = $klass.apply(undefined, argsList[i]);
			strictEqual(_flavor_Flavor, scope.flavor.Flavor, '_flavor_Flavor === scope.flavor.Flavor (' + i + ')');
			strictEqual(_flavor_Flavor, windowScope.get("flavor.Flavor"), '_flavor_Flavor === windowScope.get("flavor.Flavor") (' + i + ')');
			strictEqual(_flavor_Flavor, $klassPath("flavor.Flavor").get(), '_flavor_Flavor === $klassPath("flavor.Flavor").get() (' + i + ')');
			strictEqual(_flavor_Flavor._super, _Base, '_flavor_Flavor._super === _Base (' + i + ')');
		}
	});
});

})(jQuery, window, window.document);